package com.cloud.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cloud.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * (User)表数据库访问层
 *
 * @author makejava
 * @since 2020-11-26 13:42:56
 */
@Mapper
public interface UserDao extends BaseMapper<User> {

    /**
     * @author lc
     * @date 2020/11/27
     * @description 删除表
     */
    @Delete("DROP TABLE IF EXISTS `t_user_${id}`;")
    void delete(long id);

    @Select("CREATE TABLE `t_user_${id}`  (\n" +
            "  `user_id` bigint NOT NULL,\n" +
            "  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,\n" +
            "  `age` int NULL DEFAULT NULL,\n" +
            "  `sex` int NULL DEFAULT NULL,\n" +
            "  `create_time` datetime(0) NULL DEFAULT NULL,\n" +
            "  PRIMARY KEY (`user_id`) USING BTREE\n" +
            ") ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;")
    void create(long id);
}